/*
 * bsp_timer.h
 *
 *  Created on: 2023年6月28日
 *      Author: mcealt_DS
 */

#ifndef BSP_TIMER_H_
#define BSP_TIMER_H_

#include "em_gpio.h"
#include "em_timer.h"
#include "em_cmu.h"
#include "device_type.h"

#define PWM_TIMER_CLOCK     (cmuClock_TIMER1)
#define PWM_TIMER           (TIMER1)

#if defined(SM_SOUND) || defined(SM_OUTSOUND)
#define BEEP_PWM_CHANNEL         (0)
#define BEEP_PWM_PORT            (gpioPortC)
#define BEEP_PWM_PIN             (7)
#else
#define BEEP_PWM_CHANNEL         (0)
#define BEEP_PWM_PORT            (gpioPortC)
#define BEEP_PWM_PIN             (6)
#endif

#define PWM_FREQUENCY_DEFAULT   (1000)

void pwm_init(void);
void pwm_frequency_set(uint16_t frequency);
void pwm_frequency_preset(uint16_t frequency);
void pwm_duty_set(uint8_t channel, uint8_t duty);
void pwm_start();
void pwm_stop();
void pwm_duty_value_set(uint8_t duty);//仅设置PWM占空比的控制变量值
#endif /* BSP_TIMER_H_ */
